home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Math Functions / Sum of Wave < prev   
Text File  |  1994-02-18  |  603b  |  30 lines

  1.  
  2. | The following three functions return the sum of the y values
  3. | of a wave.  The first works from point number pStart up to
  4. |  and including point number pStop.  The second is similar
  5. | but uses x values and the third sums the entire wave.
  6. Function/D PSumWave(w,pStart,pStop)
  7.     wave/D w
  8.     variable pStart,pStop
  9.  
  10.     Variable/D sum=0
  11.     do
  12.         sum+=w[pStart]
  13.         pStart += 1
  14.     while(pStart<=pStop)
  15.     return sum
  16. end
  17.  
  18. Function/D XSumWave(w,xStart,xStop)
  19.     wave/D w
  20.     variable/D xStart,xStop
  21.  
  22.     return PSumWave(w,x2pnt(w,xStart),x2pnt(w,xStop))
  23. end
  24.  
  25. Function/D SumWave(w)
  26.     wave/D w
  27.  
  28.     return PSumWave(w,0,numpnts(w)-1)
  29. end
  30.